package com.tianyiyan.api;

import com.opensymphony.xwork2.Action;
import com.tianyiyan.dao.tyenword.UserDao;
import com.tianyiyan.hibernate.user.User;

public class SessionAction implements Action
{
	private User user;
	private Session resultSession;

	@Override
	public String execute() throws Exception
	{
		System.out.println("User: " + user);
		if (user == null)
			return ERROR;
		
		UserDao dao = new UserDao();
		
		user = dao.checkUser(user);
		
		if (user == null)
			return ERROR;
		else
		{
			resultSession = new Session(user);
			return SUCCESS;
		}
	}
	public Session getResultSession() {
		return resultSession;
	}
	public void setResultSession(Session resultSession) {
		this.resultSession = resultSession;
	}
	public User getUser() {
		return user;
	}
	
	public void setUser(User user) {
		this.user = user;
	}
}
